﻿using UnityEngine;

namespace CGF
{
    public class RedDotDemo : MonoBehaviour
    {
        public CButton[] btns;
        string[] redDots =
        {
            "Top",
            "Mid_1",
            "Mid_2",
            "Bottom_1",
            "Bottom_2",
        };

        void Start()
        {
            for (int i = 0; i < btns.Length; i++)
            {
                int index = i;
                RedDotHelper.SetNumber(redDots[i], 1);
                btns[i].triggerInterval = 0;
                btns[i].SetClick(() =>
                {
                    OnBtnClick(index);
                });
            }
        }

        void OnBtnClick(int index)
        {
            string key = redDots[index];
            int currNum = RedDotHelper.GetNumberSelf(key);
            RedDotHelper.SetNumber(key, currNum == 0 ? 1 : 0);
        }
    }
}
